﻿package mortal.game.view.interfaceCallModule
{
    import com.mui.controls.*;
    import flash.events.*;
    import mortal.game.cache.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;

    public class UITrackPanelSub2 extends GSprite
    {
        protected var btn1:GButton;
        protected var btn2:GButton;
        protected var _out1:GTextFiled;
        protected var _out2:GTextFiled;
        protected var btn3:GButton;
        protected var _out3:GTextFiled;
        public static var ckArr:Array;

        public function UITrackPanelSub2()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.btn1 = UIFactory.gButton("按钮", 30, 84, 50, 30, this);
            this.btn2 = UIFactory.gButton("按钮", 32, 233, 50, 30, this);
            this._out1 = UIFactory.gTextField("defenseBag:0", 97, 84, 460, 150, this);
            this._out1.multiline = true;
            this._out1.wordWrap = true;
            this._out2 = UIFactory.gTextField("defenseRoleEquipCache:0", 102, 234, 460, 150, this);
            this._out2.multiline = true;
            this._out2.wordWrap = true;
            this.btn3 = UIFactory.gButton("显示当前", 27, 399, 70, 30, this);
            this._out3 = UIFactory.gTextField("TextField", 112, 396, 460, 150, this);
            this._out3.multiline = true;
            this._out3.wordWrap = true;
            this.btn1.configEventListener(MouseEvent.CLICK, this.onCk1);
            this.btn2.configEventListener(MouseEvent.CLICK, this.onCk2);
            this.btn3.configEventListener(MouseEvent.CLICK, this.onCk3);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this.btn1 = null;
            this.btn2 = null;
            this._out1 = null;
            this._out2 = null;
            this.btn3 = null;
            this._out3 = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function onCk1(event:MouseEvent) : void
        {
            var _loc_2:* = Cache.instance.pack.defenseBag.allItems;
            this.showT(_loc_2, this._out1, "defenseBag:");
            return;
        }// end function

        private function onCk2(event:MouseEvent) : void
        {
            var _loc_2:* = Cache.instance.pack.defenseRoleEquipCache.allItems;
            this.showT(_loc_2, this._out2, "defenseRoleEquipCache:");
            return;
        }// end function

        private function showT(param1:Array, param2:GTextFiled, param3:String) : void
        {
            var _loc_7:ItemData = null;
            var _loc_4:int = 0;
            var _loc_5:String = "";
            var _loc_6:int = 0;
            while (_loc_6 < param1.length)
            {
                
                _loc_7 = param1[_loc_6];
                if (_loc_7 == null)
                {
                }
                else
                {
                    _loc_4 = _loc_4 + _loc_7.itemAmount;
                    _loc_5 = _loc_5 + ("," + _loc_6 + ":" + _loc_7.name + "c:" + _loc_7.itemCode);
                }
                _loc_6++;
            }
            param2.text = param3 + _loc_4 + "\n" + _loc_5;
            return;
        }// end function

        private function onCk3(event:MouseEvent) : void
        {
            var _loc_5:Object = null;
            if (ckArr == null)
            {
                return;
            }
            var _loc_2:int = 0;
            var _loc_3:String = "";
            var _loc_4:int = 0;
            while (_loc_4 < ckArr.length)
            {
                
                _loc_5 = ckArr[_loc_4];
                _loc_3 = _loc_3 + ("code:" + _loc_5.itemCode + ",");
                _loc_3 = _loc_3 + ("layer:" + _loc_5.layer + ",");
                _loc_3 = _loc_3 + ("bagNum:" + _loc_5.bagItemNum + ",");
                _loc_3 = _loc_3 + ("roleNum:" + _loc_5.roleItemNum + ",");
                _loc_3 = _loc_3 + ("name:" + _loc_5.nameStr);
                _loc_3 = _loc_3 + "\n";
                _loc_4++;
            }
            this._out3.text = "" + _loc_3;
            return;
        }// end function

        public static function addCkArr(param1:int, param2:String, param3:int) : void
        {
            var _loc_4:Object = {};
            _loc_4.itemCode = param1;
            _loc_4.nameStr = param2;
            _loc_4.layer = param3;
            _loc_4.bagItemNum = getItemNum1(param1);
            _loc_4.roleItemNum = getItemNum2(param1);
            ckArr.push(_loc_4);
            return;
        }// end function

        public static function getItemNum1(param1:int) : int
        {
            var judge:Function;
            var itemCode:* = param1;
            judge = function (param1:ItemData) : Boolean
            {
                return param1.itemCode == itemCode;
            }// end function
            ;
            var bagItemNum:* = Cache.instance.pack.defenseBag.getItemCountByJudge(judge);
            return bagItemNum;
        }// end function

        public static function getItemNum2(param1:int) : int
        {
            var judge:Function;
            var itemCode:* = param1;
            judge = function (param1:ItemData) : Boolean
            {
                return param1.itemCode == itemCode;
            }// end function
            ;
            var roleItemNum:* = Cache.instance.pack.defenseRoleEquipCache.getItemCountByJudge(judge);
            return roleItemNum;
        }// end function

        public static function getItemNum(param1:int) : int
        {
            var judge:Function;
            var itemCode:* = param1;
            judge = function (param1:ItemData) : Boolean
            {
                return param1.itemCode == itemCode;
            }// end function
            ;
            var bagItemNum:* = Cache.instance.pack.defenseBag.getItemCountByJudge(judge);
            var roleItemNum:* = Cache.instance.pack.defenseRoleEquipCache.getItemCountByJudge(judge);
            return bagItemNum + roleItemNum;
        }// end function

    }
}
